﻿using IOA.MES.DataAccess.Enum;
using System.Collections.Generic;

namespace IOA.MES.DataAccess.VModel
{
    /// <summary>
    /// 用户表
    /// </summary>
    public class VUser : BaseVModel
    {
        private string _userName = string.Empty;
        private string _email = string.Empty;
        private string _phone = string.Empty;
        private string _password = string.Empty;
        private string _avatar = string.Empty;
        private string _trueName;
        private string _language;
        private string _token;

        #region Public Property

        ///<Summary>
        /// 用户名
        ///</Summary>
        public string UserName
        {
            get { return string.IsNullOrWhiteSpace(_userName) ? string.Empty : _userName; }
            set { _userName = value; }
        }

        ///<Summary>
        /// 真实姓名
        ///</Summary>
        public string TrueName
        {
            get { return string.IsNullOrWhiteSpace(_trueName) ? string.Empty : _trueName; }
            set { _trueName = value; }
        }

        ///<Summary>
        /// 邮箱
        ///</Summary>
        public string Email
        {
            get { return string.IsNullOrWhiteSpace(_email) ? string.Empty : _email; }
            set { _email = value; }
        }

        ///<Summary>
        /// 手机号
        ///</Summary>
        public string Phone
        {
            get { return string.IsNullOrWhiteSpace(_phone) ? string.Empty : _phone; }
            set { _phone = value; }
        }

        ///<Summary>
        /// 密码
        ///</Summary>
        public string Password
        {
            get { return string.IsNullOrWhiteSpace(_password) ? string.Empty : _password; }
            set { _password = value; }
        }

        ///<Summary>
        /// 语言
        ///</Summary>
        public string Language
        {
            get { return string.IsNullOrWhiteSpace(_language) ? string.Empty : _language; }
            set { _language = value; }
        }

        ///<Summary>
        /// 头像
        ///</Summary>
        public string Avatar
        {
            get { return string.IsNullOrWhiteSpace(_avatar) ? string.Empty : _avatar; }
            set { _avatar = value; }
        }

        /// <summary>
        /// 用户状态
        /// </summary>
        public CommonStatus Status { get; set; }
        public string CNStatus { get { return !System.Enum.IsDefined(typeof(CommonStatus), Status) ? string.Empty : EnumConvert.ToDesc(Status); } }

        /// <summary>
        /// 角色列表
        /// </summary>
        public List<VRole> Roles { get; set; } = new List<VRole>();

        /// <summary>
        /// 车间列表
        /// </summary>
        public List<VWorkshop> Workshops { get; set; } = new List<VWorkshop>();

        /// <summary>
        /// 令牌
        /// </summary>
        public string Token
        {
            get { return string.IsNullOrWhiteSpace(_token) ? string.Empty : _token; }
            set { _token = value; }
        }

        /// <summary>
        /// 过站权限列表
        /// </summary>
        public List<KeyValuePair<MachineType, string>> Sites { get; set; } = new List<KeyValuePair<MachineType, string>>();
        #endregion
    }
}
